﻿using System;

using Yawf.Security.Entities;

namespace Yawf.Security {
	public interface IAuthenticationManager {
		/// <summary>
		/// Checks if a user has permission to a resource. The resource is a path to a
		/// special reource within the application, it could be a file in a file system
		/// or a url in a web application. Depending on which application is calling this 
		/// method and which class thats implementing this method.
		/// </summary>
		/// <param name="user">User object that has to be checked</param>
		/// <param name="resource">Resource that shold be checked</param>
		/// <returns>true if user has permission to resource, false otherwise</returns>
		bool HasPermisssion(IUser user,String resource);

		/// <summary>
		///  Obtains a user that has certain login. This method is generally used in the
		///  process of authentication of a user that enter to the system.
		/// </summary>
		/// <param name="login">A string that identify a user in an authentication process</param>
		/// <returns>the User associated to the login, null if user is not found</returns>
		IUser GetUserByLogin(String login);

		/// <summary>
		/// This method is used to verify the password of an user to give him access
		/// to the system.
		/// </summary>
		/// <param name="user"></param>
		/// <param name="password"></param>
		/// <returns></returns>
		bool ValidatePassword(IUser user,String password);

		/// <summary>
		/// This method allows the user to log in the System, using a username(login) 
		/// and a password.
		/// </summary>
		/// <param name="login">The username used by the user to identify himself. It must be unique.</param>
		/// <param name="password">The password to validate the identity of the user.</param>
		/// <returns>the User object for logged in user, null otherwise</returns>
		IUser Login(String login,String password);

		/// <summary>
		/// This method allows the user to log out the System.
		/// </summary>
		/// <param name="theUser">user to log out</param>
		void Logout(IUser theUser);
	
	}								// Interface
}
